<?php

/**
 * This is the model class for table "reg_health_policy".
 *
 * The followings are the available columns in table 'reg_health_policy':
 * @property integer $id
 * @property integer $mst_client_id
 * @property integer $mst_jns_asuransi_id
 * @property integer $mst_perusahaan_asuransi_id
 * @property string $policy_no
 * @property string $start_periode
 * @property string $end_periode
 * @property string $remarks
 * @property integer $mst_currency_id
 * @property string $jml_installment
 * @property integer $createdby
 * @property string $createdtime
 * @property integer $updatedby
 * @property string $updatedtime
 */
class RegHealthPolicy extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'reg_health_policy';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('mst_client_id, mst_perusahaan_asuransi_id, start_periode, end_periode', 'required'),
			array('mst_client_id, mst_jns_asuransi_id, mst_perusahaan_asuransi_id, mst_currency_id, mst_currency_detail_id, createdby, updatedby, id_cabang, mst_marketing_id', 'numerical', 'integerOnly'=>true),
			array('policy_no', 'length', 'max'=>50),
			array('file', 'length', 'max'=>100),
			array('jml_installment', 'length', 'max'=>5),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, file, id_cabang, mst_marketing_id, mst_currency_detail_id, mst_client_id, mst_jns_asuransi_id, mst_perusahaan_asuransi_id, policy_no, start_periode, end_periode, remarks, mst_currency_id, jml_installment, createdby, createdtime, updatedby, updatedtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'mst_client_id' => 'Client',
			'mst_jns_asuransi_id' => 'Jenis Asuransi',
			'mst_perusahaan_asuransi_id' => 'Perusahaan Asuransi',
			'policy_no' => 'Policy No',
			'start_periode' => 'Start Periode',
			'end_periode' => 'End Periode',
			'remarks' => 'Remarks',
			'mst_currency_id' => 'Currency',
			'jml_installment' => 'Jumlah Installment',
			'createdby' => 'Createdby',
			'createdtime' => 'Createdtime',
			'updatedby' => 'Updatedby',
			'updatedtime' => 'Updatedtime',
			'mst_currency_detail_id' => 'mst_currency_detail_id',
			'id_cabang' => 'Cabang',
			'mst_marketing_id' => 'Marketing',
			'file' => 'File',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('mst_client_id',$this->mst_client_id);
		$criteria->compare('mst_jns_asuransi_id',$this->mst_jns_asuransi_id);
		$criteria->compare('mst_perusahaan_asuransi_id',$this->mst_perusahaan_asuransi_id);
		$criteria->compare('policy_no',$this->policy_no,true);
		$criteria->compare('start_periode',$this->start_periode,true);
		$criteria->compare('end_periode',$this->end_periode,true);
		$criteria->compare('remarks',$this->remarks,true);
		$criteria->compare('mst_currency_id',$this->mst_currency_id);
		$criteria->compare('jml_installment',$this->jml_installment,true);
		$criteria->compare('createdby',$this->createdby);
		$criteria->compare('createdtime',$this->createdtime,true);
		$criteria->compare('updatedby',$this->updatedby);
		$criteria->compare('updatedtime',$this->updatedtime,true);
		$criteria->compare('mst_currency_detail_id',$this->mst_currency_detail_id,true);
		$criteria->compare('id_cabang',$this->id_cabang,true);
		$criteria->compare('mst_marketing_id',$this->mst_marketing_id,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return RegHealthPolicy the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
